package com.ygxsk.carhome.ui.rice;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.lxj.xpopup.core.AttachPopupView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.listener.DoSomeThingListener;

/*
 * @Author:itchenqi175@163.com
 * @Time:2024/1/11  9:25
 * @Description:自定义的餐券发放的右上角布局
 */
public class RiceTickAttachPopupBg extends AttachPopupView {

    private DoSomeThingListener doSomeThingListener;

    public RiceTickAttachPopupBg(@NonNull Context context, DoSomeThingListener _doSomeThingListener) {
        super(context);
        doSomeThingListener = _doSomeThingListener;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.ricetick_attach_popupbg;
    }

    @Override
    protected void onCreate() {
        super.onCreate();

        //点击事件内容：
        //餐券发放
        LinearLayout linearLayout_push = (LinearLayout) this.findViewById(R.id.linearlayout_push_rice);
        //餐券核销记录
//        LinearLayout linearLayout_dist = (LinearLayout) this.findViewById(R.id.linearlayout_dist_rice);
        //餐券扫码核销
        LinearLayout linearlayout_dist_rice_qrcode = (LinearLayout) this.findViewById(R.id.linearlayout_dist_rice_qrcode);

        linearLayout_push.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Bundle extra_bundle = new Bundle();
                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_RICE_TICKET_OUT_ACTIVITY);
                ActivityUtils.startActivity(extra_bundle, RiceTicketPushActivity.class);

                //弹窗关闭
                dismiss();
            }
        });


        linearlayout_dist_rice_qrcode.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                if (doSomeThingListener != null) {
                    doSomeThingListener.doSomeThing();
                }

                dismiss();

            }
        });

    }


    //        linearLayout_dist.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
////                Bundle extra_bundle = new Bundle();
////                //携带是从哪个页面过去的？
////                //携带标志 是从 餐券发放过去的
////                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_RICE_TICKET_OUT_ACTIVITY);
////
////                //2024-1-3 09:51:03 新增逻辑：从餐券过来和从客户关怀的优惠券过来的不同，要注意。
////                //是否是批量审核跳转携带值内容:该处是【否】，不是批量审核过来的
////                extra_bundle.putBoolean(ExtraKey.EXTRA_ISCHECKED_MORE_ITEMS_FLAG, false);
////                ActivityUtils.startActivity(extra_bundle, CardSumHistoryActivity.class);
//
////                 携带信息跳转到【编辑-提交】页面；
//                Bundle extra_bundle = new Bundle();
//                //携带是 餐券 到卡券核销 列表
//                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_RICE_TICKET_OUT_ACTIVITY);
//                ActivityUtils.startActivity(extra_bundle, CardDistHistoryActivity.class);
//                dismiss();
//
//            }
//        });


    @Override
    protected void onShow() {
        super.onShow();

        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "onShow--onShow");

    }

    @Override
    protected void onDismiss() {
        super.onDismiss();

        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "onDismiss--onDismiss");

    }


}
